<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="HandheldFriendly" content="true" />
    <meta name="MobileOptimized" content="320" />
    <link rel="stylesheet" href="./css/reset.css">
    <link rel="stylesheet" href="./css/candy-send.css">
    <link rel="stylesheet" href="./css/jiazai.css">
    <title>糖果派送</title>
</head>

<body>
    <div id='app'>

        <!-- 加载中动画 -->
        <div class='jiazai' v-if='jiazai'>
            <img src="./img/jia-ani.gif" width="50px" height="50px">
        </div>
        <!-- 加载中动画 -->

        <div class='notice-hea'>
            <img @click='close' src="./img/white-left.svg" width="20px" height="20px">
            <span>糖果盒</span>
        </div>
        <div class='candy-hea-wrap'>
            <div class='blue-content'>
                <img src="./img/candy-img.png" width="120px">
                <span>我的糖果： <span v-text='_toFixed(allMoney,6)'>0</span> </span>
            </div>
            <div class='white-title'>
                <span>糖果</span>
                <span>数量</span>
                <span>时间</span>
                <span>来源</span>
            </div>
        </div>
        <div class='candy-list-wrap'>
            <div class='candy-list' v-for="(val,index) in candyList" :key='index'>
                <div class='candy1'>
                    <img :src="HTTP+val.mcimg" width="20px" height="20px">
                    <span v-text='val.coinsname'>BTC</span>
                </div>
                <div class='candy2' v-text='_toFixed(val.money,6)'>
                    +70.00
                </div>
                <div class='candy3'>
                    <p v-text='handTime(val.addtime).split(" ")[0]'>2018/5/25</p>
                    <p v-text='handTime(val.addtime).split(" ")[1]'>12:00:252</p>
                </div>
                <div class='candy4' v-text='val.type'>
                    智能搬砖
                </div>
            </div>
        </div>
    </div>
    <script src="js/comm.js" type="text/javascript" charset="utf-8"></script>
    <script src="js/back.js" type="text/javascript" charset="utf-8"></script>
    <script src="js/jquery.min.js"></script>
    <script src="js/vue.min.js"></script>
    <script>
        var app = new Vue({
            el: '#app',
            data: {
                //加载中动画
                jiazai: false,
                //糖果列表
                candyList: [{
                    type: '智能狗',
                    addtime: 1540884048,
                    money: 0,
                    coinsname: 'spr'
                }],
                //总糖果
                allMoney: 0
            },
            created: function() {
                //糖果派送数据
                this.getData();
            },
            methods: {
                close: function() {
                    var web = plus.webview.currentWebview();
                    web.close('none');
                },
                //得到糖果派送数据
                getData: function() {
                    this.jiazai = true;
                    var This = this;
                    _post(SUGER_DISPATCH, {
                        userid: JSON.parse(localStorage.getItem('user')).userid
                    }, function(data) {
                        This.jiazai = false;
                        if (data.status == 1) {
                            This.candyList = data.back;
                            for (var i = 0; i < data.back.length; i++) {
                                This.allMoney += parseFloat(data.back[i].money);
                            }
                        } else {
                            _toast(data.msg);
                        }
                    });
                },
                //转换时间戳
                handTime: function(val) {
                    return _date(val);
                }
            }
        });
    </script>
    <script type="text/javascript" charset="utf-8">
        function plusReady() {

        }

        // 判断扩展API是否准备，否则监听'plusready'事件
        if (window.plus) {
            plusReady();
        } else {
            document.addEventListener('plusready', plusReady, false);
        }
    </script>
</body>

</html>